package com.zh.demo02.controller;

import com.zh.demo02.verifycode.sms.SmsCodeService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ZH
 * @date 16:15 2021-01-08
 */
@Slf4j
@RestController
@RequestMapping("/code")
public class VerifyCodeController {
    @Autowired
    private SmsCodeService smsCodeGenerator;

    /**
     * 生成手机验证码
     *
     * @param req
     * @param resp
     */
    @GetMapping("/sms")
    public void smsCode(HttpServletRequest req, HttpServletResponse resp) {
        log.debug("call smsCode() ...");
        //生成验证码，并返回
        smsCodeGenerator.createAndSend(req, resp);
    }

}
